package structures.compare;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class CompareLine implements Serializable{

	private List<CompareCell> cells;
	private boolean hasDifferentValues;
	private boolean hasNotReturnedValues;
	
	public CompareLine() {
		super();
		cells = new ArrayList<CompareCell>();
	}

	public List<CompareCell> getCells() {
		return cells;
	}

	public void setCells(List<CompareCell> cells) {
		this.cells = cells;
	}
	
	public void fillRow(Integer index){
		while(cells.size() < index){
			cells.add(new CompareCell("<<Not Returned>>"));
		}
	}
	public void addCell(String value, Integer index){
		fillRow(index);
		setRowState(value);
		cells.add(new CompareCell(value));
	}
	public CompareCell getCell(Integer index){
		return cells.get(index);
	}
	public void setRowState(String value){
		for (CompareCell cell : cells) {
			if(!value.equals(cell.getValue())){
				hasDifferentValues = !cell.getValue().equalsIgnoreCase("<<Not Returned>>");
				hasNotReturnedValues = ! hasDifferentValues;
				break;
			}
		}
	}

	public boolean isHasDifferentValues() {
		return hasDifferentValues;
	}

	public void setHasDifferentValues(boolean hasDifferentValues) {
		this.hasDifferentValues = hasDifferentValues;
	}

	public boolean isHasNotReturnedValues() {
		return hasNotReturnedValues;
	}

	public void setHasNotReturnedValues(boolean hasNotReturnedValues) {
		this.hasNotReturnedValues = hasNotReturnedValues;
	}
	
	public String getStyleClass(){
		String styleClass = "";
		if(hasDifferentValues){
			styleClass = "different-values";
		}
		else if(hasNotReturnedValues){
			styleClass = "not-returned-values";
		}
		return styleClass;
	}
	
}
